package name

import "fmt"


type Name struct {
	ModuleName  string
	ItemName    string
}
func MakeName(mod string, item string) Name {
	return Name {
		ModuleName: mod,
		ItemName:   item,
	}
}
func (n Name) String() string {
	if n.ModuleName == "" {
		return n.ItemName
	} else {
		return fmt.Sprintf("%s::%s", n.ModuleName, n.ItemName)
	}
}

type TypeName struct {
	Name
}
func MakeTypeName(mod string, item string) TypeName {
	return TypeName { Name: MakeName(mod, item) }
}
func (n TypeName) String() string {
	return n.Name.String()
}

type FunctionName struct {
	Name
	Tag  string
}
func (n FunctionName) String() string {
	if n.Tag != "" {
		return fmt.Sprintf("%s#%s", n.Name.String(), n.Tag)
	} else {
		return n.Name.String()
	}
}
func FunctionNameTagFromSource(index uint) string {
	return fmt.Sprintf("src-%d", index)
}
func FunctionNameTagGenerated(id string) string {
	return fmt.Sprintf("gen-%s", id)
}


